<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->


    <link href="__ADMIN_TMPL__/public/assets/themes/{:cmf_get_admin_style()}/bootstrap.min.css" rel="stylesheet">
    <link href="__ADMIN_TMPL__/public/assets/simpleboot3/css/simplebootadmin.css" rel="stylesheet">
    <link href="__ADMIN_TMPL__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        form .input-order {
            margin-bottom: 0px;
            padding: 0 2px;
            width: 42px;
            font-size: 12px;
        }

        form .input-order:focus {
            outline: none;
        }

        .table-actions {
            margin-top: 5px;
            margin-bottom: 5px;
            padding: 0px;
        }

        .table-list {
            margin-bottom: 0px;
        }

        .form-required {
            color: red;
        }
    </style>
    <script type="text/javascript">
        //全局变量
        var GV = {
            ROOT: "__ROOT__/",
            WEB_ROOT: "__WEB_ROOT__/",
            JS_ROOT: "static/js/",
            APP: '{$Request.module}'/*当前应用名*/
        };
    </script>
    <script src="__ADMIN_TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
    <script src="__STATIC__/js/wind.js"></script>
    <script src="__ADMIN_TMPL__/public/assets/js/bootstrap.min.js"></script>
    <script>
        Wind.css('artDialog');
        Wind.css('layer');
        $(function () {
            $("[data-toggle='tooltip']").tooltip({
                container:'body',
                html:true,
            });
            $("li.dropdown").hover(function () {
                $(this).addClass("open");
            }, function () {
                $(this).removeClass("open");
            });
        });
    </script>
    <if condition="APP_DEBUG">
        <style>
            #think_page_trace_open {
                z-index: 9999;
            }
        </style>
    </if>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:cmf_plugin_url('QbtDbBackup://AdminIndex/index')}">数据备份</a></li>
        <li class="active"><a href="javascript:void(0)">数据还原</a></li>
    </ul>
    <form action="" method="post" class="margin-top-20">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>备份表数量</th>
                <th>备份时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="list" item="vo">
                <tr>
                    <td>{$vo['table_num']}</td>
                    <td>{:date("Y-m-d H:i:s",$vo['create_time'])}</td>
                    <td>
                        <a href="{:cmf_plugin_url('QbtDbBackup://AdminIndex/lists',['dir'=>date('YmdHis',$vo['create_time'])])}">详情</a>
                        <a href="__WEB_ROOT__/data/db{:date('YmdHis',$vo['create_time'])}/{:date('YmdHis',$vo['create_time'])}.sql" download>下载</a>
                        <a class="js-ajax-delete" href="{:cmf_plugin_url('QbtDbBackup://AdminIndex/del',['id'=>$vo['id']])}">删除</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/js/noty/noty-2.4.1.js"></script>
<script>
    function restore() {
        var str=[];
        $(".js-check").each(function(){
            if ($(this).is(':checked')){
                str.push($(this).val());
            }
        });
        if (str.length==0){
            $(".ts").show();
        }else{
            $.ajax({
                type: "GET",
                url: "{:cmf_plugin_url('QbtDbBackup://AdminIndex/restore')}",
                data: {str:str},
                dataType: "json",
                success: function(data){
                    if (data==1){
                        noty({text: "还原成功", type: 'success',layout: "topCenter", timeout: 2000});
                    }else{
                        noty({text: "还原失败，请稍后重试", type: 'error',layout: "topCenter", timeout: 2000});
                    }
                }
            });
        }
    }
</script>
</body>
</html>